<?php
if (isset($InputData['list_type'])) {
    require_once("{$CfgPara->root}/model/shoe_show.m.php");
    $myShoeShow = new shoe_show_m($CfgPara->database);
    $shoeShowListId = 0;
    $InputData['list_type'] = (int)$InputData['list_type'];
    /**
     * pc版管理列表名称
     */
    $manage_view = '';
    if ($InputData['list_type'] == shoe_show_m::ListHot
        || $InputData['list_type'] == shoe_show_m::ListNew
        || $InputData['list_type'] == shoe_show_m::ListClient
    ) {
        $shoeShowListId = 0;
        if ($isTablet === false)
            $shoeShowCount = -2; // 手机端为下拉加载 无需查询总数量
        else
            $shoeShowCount = -1; // PC端需要分页 查询时获取总量
        if ($isTablet === TRUE &&
            $InputData['list_type'] == shoe_show_m::ListNew &&
            isset($InputData['search_content']) &&
            $InputData['search_content'] == 'shoe_show_list'
        ) {
            $manage_view = '_manage';
        }
        if (isset($InputData['page_iscroll_load']) && $InputData['page_iscroll_load'] == 1) {
            $seleBarItem = $InputData['list_type'];
            $seleBarItem1 = "热门";
            $seleBarItem2 = "最新";
            $seleBarItem3 = "客户";
            $seleBarScript1 = "shoe_show_list(1,1)";
            $seleBarScript2 = "shoe_show_list(2,1)";
            $seleBarScript3 = "shoe_show_list(3,1)";
            require("{$viewRoot}list_sele_bar{$viewEx}");
        }
    } elseif ($InputData['list_type'] == shoe_show_m::ListMyCollect) {
        if (!isset($InputData['page_change'])) {
            $searchTittle = '收藏夹的鞋主秀';
            require("{$viewRoot}search_bar{$viewEx}");
        }
        $shoeShowCount = -1;
    } elseif ($InputData['list_type'] == shoe_show_m::ListMine)//我的鞋主秀
    {
        if ($isTablet === TRUE) {
            $manage_view = '_manage';
        }
        if (isset($InputData['works_user_id'])) {
            $shoeShowListId = $InputData['works_user_id'];
            $shoeShowCount = $myShoeShow->show_count(shoe_show_m::CountMine, $shoeShowListId);
            $tittleText = '他发表的鞋主秀';
            require("{$viewRoot}tittle_back_bar{$viewEx}");
        } elseif (isset($_SESSION['user_id'])) {
            $shoeShowListId = $_SESSION['user_id'];
            if (!isset($InputData['page_change'])) {
                $searchTittle = '我的鞋主秀';
                require("{$viewRoot}search_bar{$viewEx}");
            }
            if (!isset($InputData['search_text'])) {
                $shoeShowCount = $myShoeShow->show_count(shoe_show_m::CountMine, $shoeShowListId);
            } else {
                //如果为搜索，查询时才确定总数
                $shoeShowCount = -1;
            }
        } else {
            require("{$CfgPara->root}/controller/user_login.c.php"); //未登陆则申请登陆
            goto page_end;
        }
    } elseif ($InputData['list_type'] == shoe_show_m::ListForWork1)//作品页面下的鞋主秀
    {
        $shoeShowListId = $InputData['work_id'];
    } else {
        echo('鞋主秀列表类型错误');
        goto page_end;
    }
    if (isset($InputData['page_change']) && $InputData['page_change'] > 0) {
        $page_index = $InputData['page_change'];
    } else {
        $page_index = 1;
    }
    if (isset($InputData['search_text'])
        && isset($InputData['search_content'])
        && $InputData['search_content'] == 'shoe_show_list'
    ) {
        //如果有搜索内容 则增加搜索文本 且得出总数量
        $change_page_func = "get_search([x])";
        if ($page_index != 1 &&
            isset($InputData['search_result_count']) &&
            is_numeric($InputData['search_result_count']) &&
            $InputData['search_result_count'] >= 0
        ) {
            //如果页面已经记录过搜索结果总数量
            $shoeShowList = $myShoeShow->show_list(
                $InputData['list_type'],
                $shoeShowListId, $page_index,
                $CfgPara->pagesize,
                $InputData['search_text']);
            $shoeShowCount = $InputData['search_result_count'];
        } else {
            //如果页面为第一页 或没记录过总数量
            $shoeShowList = $myShoeShow->show_list(
                $InputData['list_type'],
                $shoeShowListId, $page_index,
                $CfgPara->pagesize,
                $InputData['search_text'], TRUE);
            $shoeShowCount = $myShoeShow->show_list_count;
        }
        //返回的结果用连续两个||符号分隔 总数量与内容
        echo $shoeShowCount . '||';
    } else {
        $change_page_func = "shoe_show_page_change({$InputData['list_type']},[x])";
        if ($shoeShowCount === -1) // 查询时同时获取总量
        {
            $shoeShowList = $myShoeShow->show_list(
                $InputData['list_type'],
                $shoeShowListId, $page_index,
                $CfgPara->pagesize,
                NULL, TRUE);
            $shoeShowCount = $myShoeShow->show_list_count;
        } else {
            $shoeShowList = $myShoeShow->show_list(
                $InputData['list_type'],
                $shoeShowListId, $page_index,
                $CfgPara->pagesize);
        }
    }
    if (is_string($shoeShowList)) {
        echo($shoeShowList);
    } else {
        if (isset($shoeShowCount) && isset($change_page_func)) {
            // 如果为手机端 且列表类型为热门、最新、客户 此为使用下拉加载
            if ($shoeShowCount != -2) {
                // 连接分页类 在列表最后加入分页栏
                require_once("{$CfgPara->root}/class/paginate.class.php");
                $myPaginate = new paginate_c();
                $myPaginate->change_func = $change_page_func;
                $paginateMsg = $myPaginate->paginate($page_index, ceil($shoeShowCount / $CfgPara->pagesize));
            }
        }
        if ((isset($InputData['page_iscroll_load']) && $InputData['page_iscroll_load'] == 1) || !isset($InputData['page_change'])) {
            require("{$viewRoot}shoe_show{$manage_view}_list{$viewEx}");//连接整个页面视图
        } elseif ((isset($InputData['page_iscroll_load']) && $InputData['page_iscroll_load'] == 2))//滚动加载 则只需要内容
            require("{$viewRoot}shoe_show{$manage_view}_list_content{$viewEx}");//加载 只需要内容
        else
            require("{$viewRoot}shoe_show{$manage_view}_list_page{$viewEx}");//页面切换 只需要页面
    }
}

page_end:;